package com.example.user.contrller;

import com.example.common.util.R;
import com.example.model.user.dto.UserRelationDto;
import com.example.user.service.UserFollowService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/api/v1/")
@Tag(name = "关注管理")
public class UserFollowController {
    @Autowired
    private UserFollowService userFollowService;

    @PostMapping(value = "userFollow/user_follow")
    @Operation(summary = "关注用户")
    public R userFollow(@RequestBody UserRelationDto userRelationDto) {
        boolean flag = userFollowService.userFollow(userRelationDto);
        if (flag) {
            return R.ok(userRelationDto.getOperation() == 0 ? "关注用户成功" : "取消关注用户成功");
        } else {
            return R.error(userRelationDto.getOperation() == 0 ? "关注用户失败" : "取消关注用户失败");
        }
    }
}
